#include <bits/stdc++.h>

using namespace std;
const int N = 1e5 + 10;

int f[N];
int n;

int main()
{
    cin >> n;
    for (int i = 0; i < n; ++i)
    {
        cin >> f[i];
    }
    sort(f, f + n);
    long long sum = 0;
    for (int i = 0; i < n - 1; ++i)
    {
        sum += f[i] * (n - i - 1);
    }
    cout << sum;
    return 0;
}